package com.contact;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.android.ocean.base.ExitApplication;
import com.matang.R;
import com.modle.HolderHeader;

/**
 * 
 * @ClassName:BaseActivity基类Activity
 * @Description:TODO
 * @author zhuw
 * @date 2012-12-19 下午5:24:29
 */
public abstract class BaseActivity extends Activity {
	protected Context mContext = null;
	protected String TAG="";
	ProgressDialog progressDialog;// 加载进度框
	protected String mLabel = "";
	public HolderHeader header;// title

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mContext = this;
		ExitApplication.getInstance().addActivity(this);
	}

	/**
	 * 显示进度框
	 */
	protected void showProgressDialog() {
		if (null == progressDialog) {
			progressDialog = new ProgressDialog(mContext);
		}
		progressDialog.setMessage("数据加载中,请稍后...");
		progressDialog.setCancelable(true);
		progressDialog.show();
	}

	protected void showProgressDialog(String msg) {
		if (null == progressDialog) {
			progressDialog = new ProgressDialog(mContext);
		}
		progressDialog.setMessage(msg);
		progressDialog.setCancelable(true);
		progressDialog.show();
	}

	/**
	 * 关闭进度框
	 */
	protected void dismissProgressDialog() {
		if (null != progressDialog && progressDialog.isShowing()) {
			progressDialog.dismiss();
		}
	}

	private void initHeader() {
		header = new HolderHeader();
		header.headLeftTv = (TextView) findViewById(R.id.headLeft);
		header.headTitleTv = (TextView) findViewById(R.id.headTitle);
		header.headRightTv = (TextView) findViewById(R.id.headRight);
		header.hContainer = (RelativeLayout) findViewById(R.id.headRl);

	}

	/**
	 * 
	 * @Description:TODO初始化标题
	 * @return void
	 * @author zhuw
	 * @date 2013-4-15 下午2:56:42
	 */
	protected void findViews() {
		initHeader();

	}

	/**
	 * 
	 * @Description:TODO初始化view的数据及动作，如设置文字、事件
	 * @return void
	 * @author zhuw
	 * @date 2013-4-15 下午3:02:16
	 */
	protected void initPaneData() {
		header.headLeftTv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				finish();

			}
		});

	}
	//
	// protected void exit() {
	// finish();
	// overridePendingTransition(R.anim.smooth_slide_from_left_in,
	// R.anim.smooth_slide_from_right_out);
	//
	// }

	// @Override
	// public boolean onKeyDown(int keyCode, KeyEvent event) {
	// if (keyCode == KeyEvent.KEYCODE_BACK) {
	// // exit();
	// return true;
	// }
	// return super.onKeyDown(keyCode, event);
	// }
}